import { screen, imageResource, keyboard, Key, mouse, centerOf, straightTo, Button, linear, clipboard, sleep } from '@nut-tree/nut-js';
import '@nut-tree/template-matcher';

// 3、创建群组
export default async function createGroup() {
    // 1.1、点击“创建群聊”Icon
    let region = await screen.find(imageResource('创建群聊Icon-template.png'), { confidence: 0.7 });
    await mouse.move(straightTo(centerOf(region)), linear(500));
    await mouse.click(Button.LEFT);
    
    // 1.2、输入联系人姓名
    region = await screen.waitFor(imageResource('创建群聊按钮-disabled-template.png'), 6000, 500, { confidence: 0.7 });
    // await keyboard.type('技术顽童');
    await clipboard.setContent('技术顽童');
    await keyboard.pressKey(Key.LeftControl, Key.V);
    await keyboard.releaseKey(Key.LeftControl, Key.V);
    await sleep(1000);
    await keyboard.pressKey(Key.Enter);
    await keyboard.releaseKey(Key.Enter);

    // 1.3、点击创建群聊按钮
    region = await screen.waitFor(imageResource('创建群聊按钮-template.png'), 6000, 500, { confidence: 0.7 });
    await mouse.move(straightTo(centerOf(region)), linear(500));
    await mouse.click(Button.LEFT);

}